package com.stylefeng.guns.biz.app.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.modular.platform.model.SellerDemand;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.biz.app.model.TAppList;
import com.stylefeng.guns.biz.app.service.ITAppListService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-06-14 02:11:10
 */
@Controller
@RequestMapping("/tAppList")
public class TAppListController extends BaseController {

	private String PREFIX = "/app/tAppList/";

	@Autowired
	private ITAppListService tAppListService;

	/**
	 * 跳转到首页
	 */
	@RequestMapping("")
	public String index() {
		return PREFIX + "tAppList.html";
	}

	/**
	 * 跳转到添加
	 */
	@RequestMapping("/tAppList_add")
	public String tAppListAdd() {
		return PREFIX + "tAppList_add.html";
	}

	/**
	 * 跳转到修改
	 */
	@RequestMapping("/tAppList_update/{tAppListId}")
	public String tAppListUpdate(@PathVariable Integer tAppListId, Model model) {
		TAppList tAppList = tAppListService.selectById(tAppListId);
		model.addAttribute("item", tAppList);
		LogObjectHolder.me().set(tAppList);
		return PREFIX + "tAppList_edit.html";
	}

	/**
	 * 获取列表
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public Object list(String condition) {
		return tAppListService.selectList(null);
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add")
	@ResponseBody
	public Object add(TAppList tAppList) {
		tAppListService.insert(tAppList);
		return SUCCESS_TIP;
	}

	/**
	 * 删除
	 */
	@RequestMapping(value = "/delete")
	@ResponseBody
	public Object delete(@RequestParam Long tAppListId) {
		tAppListService.deleteById(tAppListId);
		return SUCCESS_TIP;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/update")
	@ResponseBody
	public Object update(TAppList tAppList) {
		tAppListService.updateById(tAppList);
		return SUCCESS_TIP;
	}

	/**
	 * 详情
	 */
	@RequestMapping(value = "/detail/{tAppListId}")
	@ResponseBody
	public Object detail(@PathVariable("tAppListId") Integer tAppListId) {
		return tAppListService.selectById(tAppListId);
	}

	/**
	 * 详情
	 */
	@RequestMapping(value = "/detailInfo")
	@ResponseBody
	public Object detailInfo(String appid, Model model) {
		EntityWrapper<TAppList> wp = new EntityWrapper<TAppList>();
		wp.eq("app_id", appid);
		TAppList tAppList = tAppListService.selectOne(wp); 
		return tAppList;
	}
	
	/**
	 * 详情
	 */
	@RequestMapping(value = "/detailsPage") 
	public String detailsPage() {
		return PREFIX + "tAppList_detail.html";
	}
}
